<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let xin = [10,20,30]
        let keyArr = xin.keys()
        for (const val of keyArr) {
            console.log(val);
        }
        // 获取到所有的值，可遍历的对象
        let valArr = xin.values()
        for (const val of valArr) {
            console.log(val);
        }
        // 获取到 下标和值的组合
        let entArr = xin.entries()
        for (const val of entArr) {
            console.log('-------',val[0]);
            console.log('-------',val[1]);
            let [k,v] = val
        }
        for (const [k,v] of entArr) {
            console.log('-----',k);
            console.log('-----',v);
        }
        // 扁平化处理 减少数组的嵌套
        // let arr = [10,20,'张三','李四','a','b']
        let arr = [10,20,['张三','李四',['a','b']]]
        // 默认只去一层
        // xin = arr.flat()
        // 指定所去的层数  超过所去层数不改变
        // let wei = [x,y]
        let erwei = [[1,1],[1,2],[1,-3]]
        xin = erwei.flat(2)
        console.log(xin);

    </script>
</body>
</html>